#import <Cocoa/Cocoa.h>
#import "BWGrid.h"

typedef enum {
    BWStitch_NoArrow,
    BWStitch_Arrow
} BWStitch_ArrowKind;

extern NSString *BWStitch_StitchChangedNotification;


#define BWStitch_NO_TRANSIENT_VALUE (nanf("stitch"))


@interface BWStitch : NSObject <NSCopying, NSCoding>
{
    NSMutableDictionary *attributes;

    // these don't get stored - just for undo operations
    float transientWidth;
    NSColor *transientFillColor;
    float transientBendFactor;
    float transientBendDisplacement;
    float transientBendFlatness;

    float transientArrowLength;
    float transientArrowWeight;
    NSColor *transientArrowColor;

    float transientStartLabelDisplacement;
    float transientEndLabelDisplacement;
    float transientStartLabelDisplacementAngle;
    float transientEndLabelDisplacementAngle;

    // BWGrid_InvalidSquare for a non-transient value
    BWGrid_Square transientStartSquare;
    BWGrid_SquarePart transientStartSquarePart;
    BWGrid_Square transientEndSquare;
    BWGrid_SquarePart transientEndSquarePart;
}

// all attribute setting and getting are in categories

- (void) flip;

@end // BWStitch


@interface BWStitch(LocationAttributes)

- (void) setStartSquare: (BWGrid_Square) square
                   part: (BWGrid_SquarePart) part;

- (void) getStartSquare: (BWGrid_Square *) square
                   part: (BWGrid_SquarePart *) part;

- (BWGrid_SquarePart) getStartPart;

- (void) setTransientStartSquare: (BWGrid_Square) square
                            part: (BWGrid_SquarePart) part;

- (void) getTransientStartSquare: (BWGrid_Square *) square
                            part: (BWGrid_SquarePart *) part;



- (void) setEndSquare: (BWGrid_Square) square
                 part: (BWGrid_SquarePart) part;

- (void) getEndSquare: (BWGrid_Square *) square
                 part: (BWGrid_SquarePart *) part;

- (BWGrid_SquarePart) getEndPart;

- (void) setTransientEndSquare: (BWGrid_Square) square
                          part: (BWGrid_SquarePart) part;

- (void) getTransientEndSquare: (BWGrid_Square *) square
                          part: (BWGrid_SquarePart *) part;

@end // BWStitch location attributes


@interface BWStitch(SizeAttributes)

- (void) setWidth: (float) width;
- (float) width;

- (void) setTransientWidth: (float) transientWidth;
- (float) transientWidth;

@end // BWStitch size attributes


@interface BWStitch(ColorAttributes)

- (void) setFillColor: (NSColor *) color;
- (NSColor *) fillColor; // defaults to white

- (void) setTransientFillColor: (NSColor *) color;
- (NSColor *) transientFillColor; // defaults to white

- (void) setStrokeColor: (NSColor *) color;
- (NSColor *) strokeColor; // defaults to black

@end // BWStitch color attributes


@interface BWStitch(BendyAttributes)

// displacement from primary axis
- (void) setBendFactor: (float) bnndFactor;
- (float) bendFactor;

- (void) setTransientBendFactor: (float) bendFactor;
- (float) transientBendFactor;

// displacement along primary axis
- (void) setBendDisplacement: (float) bendDisplacement;
- (float) bendDisplacement;

- (void) setTransientBendDisplacement: (float) bendDisplacement;
- (float) transientBendDisplacement;


// how far to spread the control points
- (void) setBendFlatness: (float) bendFlatness;
- (float) bendFlatness;

- (void) setTransientBendFlatness: (float) bendFlatness;
- (float) transientBendFlatness;

@end // BWStitch bendy attributes



@interface BWStitch(LabelAttributes)

- (void) setStartLabelVisibility: (BOOL) onOff;
- (BOOL) startLabelVisibility;

- (void) setEndLabelVisibility: (BOOL) onOff;
- (BOOL) endLabelVisibility;

- (void) setStartLabelInsideStitch: (BOOL) onOff;
- (BOOL) startLabelInsideStitch;

- (void) setEndLabelInsideStitch: (BOOL) onOff;
- (BOOL) endLabelInsideStitch;

- (void) setCustomStartLabel: (NSString *) label; // nil for default
- (NSString*) customStartLabel; // nil is default

- (void) setCustomEndLabel: (NSString *) label;   // nil for default
- (NSString*) customEndLabel; // nil is default

- (void) setStartLabelDisplacement: (float) displacement;
- (float) startLabelDisplacement;

- (void) setTransientStartLabelDisplacement: (float) displacement;
- (float) transientStartLabelDisplacement;

- (void) setEndLabelDisplacement: (float) displacement;
- (float) endLabelDisplacement;

- (void) setTransientEndLabelDisplacement: (float) displacement;
- (float) transientEndLabelDisplacement;

- (void) setStartLabelDisplacementAngle: (float) angleInDegrees;
- (float) startLabelDisplacementAngle;

- (void) setTransientStartLabelDisplacementAngle: (float) angleInDegrees;
- (float) transientStartLabelDisplacementAngle;

- (void) setEndLabelDisplacementAngle: (float) angleInDegrees;
- (float) endLabelDisplacementAngle;

- (void) setTransientEndLabelDisplacementAngle: (float) angleInDegrees;
- (float) transientEndLabelDisplacementAngle;

@end // BWStitch Label Attributes


@interface BWStitch(ArrowAttributes)

- (void) setArrow: (BWStitch_ArrowKind) arrow;
- (BWStitch_ArrowKind) arrow;

- (void) setArrowWeight: (float) weight; // line thickness, basically
- (float) arrowWeight;

- (void) setTransientArrowWeight: (float) weight;
- (float) transientArrowWeight;

- (void) setArrowLength: (float) length;  // absolute length
- (float) arrowLength;

- (void) setTransientArrowLength: (float) length;
- (float) transientArrowLength;

- (void) setArrowColor: (NSColor *) color;
- (NSColor *) arrowColor; // defaults to black

- (void) setTransientArrowColor: (NSColor *) color;
- (NSColor *) transientArrowColor;

@end // BWStitch arrow attributes.  arrowed!  burnination!



@interface BWStitch(DebugAttributes)

// debug features

- (void) setDisplayDebugControlPoints: (BOOL) onOff;
- (BOOL) displayDebugControlPoints;

@end // BWStitch Debug Attributes
